import request from 'utils/request'

// 登录
const login = (params ={}) => request.post('/api/adminLogin',params)

// 商品管理
// 列表
const productList = (params ={}) => request.get(`/api/admin/product/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`)

// 新增
const productAdd = (params ={}) => request.post('/api/admin/product/add',params)

// 分类列表
const categoryList = () => request.get('/api/category/list')

// 上下架
const batchUpdateSellStatus = (params) => request.post(`/api/admin/product/batchUpdateSellStatus?ids=${params.ids}&sellStatus=${params.sellStatus}`)

// 修改
const productUpdate =(params={}) => request.post('/api/admin/product/update', params)

// 删除
const productDelete =(id) => request.post(`/api/admin/product/delete?id=${id}`)

// 分类管理
const adminCategoryList =(params) => request.get(`/api/admin/category/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`)

// 修改
const categoryUpdate =(params) => request.post('/api/admin/category/update', params)

// 删除
const categoryDelete =(id) => request.post(`/api/admin/category/delete?id=${id}`)

// 添加
const categoryAdd = (params) => request.post(`/api/admin/category/add`, params)

// 订单管理
// list
const orderList = (params) => request.get(`/api/admin/order/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`)

// 发货
const orderDelivered = (orderNo) => request.post(`/api/admin/order/delivered?orderNo=${orderNo}`)

// 完结
const orderFinish = (orderNo) => request.post(`/api/order/finish?orderNo=${orderNo}`)

export {
  login,
  productList,
  categoryList,
  batchUpdateSellStatus,
  productAdd,
  productUpdate,
  productDelete,
  adminCategoryList,
  categoryUpdate,
  categoryDelete,
  categoryAdd,
  orderList,
  orderDelivered,
  orderFinish
}